<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
   /*求和函数，确定有多少参数*/
  function sum(){
      var total=0;
      for(var i=0;i<=100;i++){
          total+=i;
//          console.log(total);
      }
      return total;
  }
//  console.log(sum());
//  求和函数，不确定有多少参数
  function sum1(){
      var nResult=0;
      for(var i=0,l=arguments.length;i<l;i++){
          nResult+=(!isNaN(arguments[i]))&&parseFloat(arguments[i])||0;
      }
      return nResult.toFixed(3)*1000/1000;//作用是保留三位有效数字，并且去掉末尾的0，最后一位会进行四舍五入
  }
 console.log( sum1(1,2,3,4,5));
  console.log( sum1(5,null,-5));
   console.log( sum1(0.1,0.2));
   function Person(){}
   Person.prototype.age=29;
   Person.prototype.name='boy';
   Person.prototype.sayName=function(){
       alert(this.name);
   }
   var person1=new Person();//person1继承了Person的全部属性和方法
   person1.name='Greg';
   console.log(person1.hasOwnProperty('name'));
   for(var prop in person1){
       console.log(prop);
   }
</script>

</body>
</html>